package org.example.mapreduce.sort;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import org.example.mapreduce.FlowWritable;

import java.io.IOException;

/**
 * @author zhl
 * @version 1.0
 * @ClassName
 * @date 2020/11/12 19:21
 */
public class FlowSortMapper extends Mapper<Object, Text, FlowWritable, NullWritable> {
    @Override
    protected void map(Object key, Text value, Context context) throws IOException, InterruptedException {
//        System.out.println("value:" + value);
        String[] token = value.toString().split("\\s+");
        for (String s : token) {
            System.out.println("token:"+s);
        }
        context.write(new FlowWritable(token[0], Long.parseLong(token[1]), Long.parseLong(token[2])),  NullWritable.get());
    }
}
